package com.hksj.cbm.controller;

import com.hksj.cbm.dto.SpaceDeviceBindDTO;
import com.hksj.cbm.dto.SpecialitySpaceBindDTO;
import com.hksj.cbm.entity.SpaceModel;
import com.hksj.cbm.service.ScreenDeviceSpaceSpecialityService;
import com.hksj.cbm.vo.ScreenDeviceSpaceSpecialityVO;
import com.hksj.cbm.vo.SpaceModelVO;
import com.hksj.common.core.model.Rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zengke
 * @version 1.0
 * @see ScreenSpecialitySpaceDeviceController
 * @since 2024/7/19 8:43
 */

@RestController
@RequestMapping("/api/screenSpecialitySpaceDevice")
@Api(tags = "基础模块-大屏专业空间设备关系")
public class ScreenSpecialitySpaceDeviceController {

    @Autowired
    private ScreenDeviceSpaceSpecialityService screenDeviceSpaceSpecialityService;

    @ApiOperation(value = "查询专业模型下的空间模型绑定关系")
    @PostMapping("/queryBindSpaceModelList")
    public Rest<List<ScreenDeviceSpaceSpecialityVO>> queryBindSpaceModelList(Long specialityModelId){
        List<ScreenDeviceSpaceSpecialityVO> screenDeviceSpaceSpecialityList = screenDeviceSpaceSpecialityService.queryBindSpaceModelList(specialityModelId);

        return Rest.ok(screenDeviceSpaceSpecialityList);
    }

    @ApiOperation(value = "绑定专业模型下的空间模型")
    @PostMapping("/bindSpaceModel")
    public Rest<String> bindSpaceModel(@RequestBody SpecialitySpaceBindDTO specialitySpaceBindDTO){
        String result = screenDeviceSpaceSpecialityService.bindSpaceModel(specialitySpaceBindDTO);
        return Rest.ok(result);
    }

    @ApiOperation(value = "查询空间模型的设备模型绑定关系")
    @PostMapping("/queryBindDeviceModelList")
    public Rest<List<ScreenDeviceSpaceSpecialityVO>> queryBindDeviceModelList(Long specialityModelId,Long spaceModelId){
        List<ScreenDeviceSpaceSpecialityVO> screenDeviceSpaceSpecialityList = screenDeviceSpaceSpecialityService.queryBindDeviceModelList(specialityModelId, spaceModelId);
        return Rest.ok(screenDeviceSpaceSpecialityList);
    }

    @ApiOperation(value = "绑定空间模型和设备模型的关系")
    @PostMapping("/bindDeviceModel")
    public Rest<String> bindDeviceModel(@RequestBody SpaceDeviceBindDTO spaceDeviceBindDTO){
        String result = screenDeviceSpaceSpecialityService.bindDeviceModel(spaceDeviceBindDTO);
        return Rest.ok(result);
    }

    @ApiOperation(value = "查询大屏空间模型树")
    @PostMapping("/queryScreenSpaceModelTree")
    private Rest<List<SpaceModel>> queryScreenSpaceModelTree(String specialityCode){
        List<SpaceModel> screenSpaceModelTree = screenDeviceSpaceSpecialityService.queryScreenSpaceModelTree(specialityCode);
        return Rest.ok(screenSpaceModelTree);
    }
}
